package com.qfedu.controller;

import com.qfedu.pojo.req.OrderReq;
import com.qfedu.pojo.req.OrdersReq;
import com.qfedu.pojo.resp.BaseResp;
import com.qfedu.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author:User
 * @time:2022/9/27
 * @explain:
 */
@RestController
@RequestMapping("/order")
public class OrderServlet {

    @Autowired
    private OrderService orderService;

    /**
     * 添加订单项(商品)
     * @return
     */
    @PostMapping("/addOrder")
    public BaseResp addOrder(@RequestBody OrderReq orderReq){
        BaseResp baseResp = orderService.addOrder(orderReq);
        return baseResp;

    }
    /**
     * 查询所有订单项
     */
    @PostMapping("/findAll")
    public BaseResp findAll(@RequestBody OrderReq orderReq){
        BaseResp all = orderService.findAll(orderReq.getOrderId());
        return all;
    }
    /**
     * 修改订单项(商品)
     */
    @PostMapping("/updateOrder")
    public BaseResp updateOrder(@RequestBody OrderReq orderReq){
        BaseResp baseResp = orderService.updateOrder(orderReq);
        return baseResp;
    }
    /**
     * 删除订单项
     */
    @PostMapping("/delOrder")
    public BaseResp delOrder(@RequestBody OrderReq orderReq){
        BaseResp baseResp = orderService.delOrder(orderReq);
        return baseResp;
    }
}
